<?php
function smarty_prefilter_changepath($tpl_source,&$smarty)
{
    $tpl_source = preg_replace("/(<(img.*?src|link.*?href|input.*?src|script.*?src|embed.*?src|script.*?basepath)\s*=\s*([\"']))(.*?)(\\3.*?>)/is","\${1}templates/\$4\$5",$tpl_source);
  
    $tpl_source = preg_replace("/(background-image.*?url)(\s*\()(.*?)(\))/is","\$1\${2}templates/\$3\$4",$tpl_source);

    return $tpl_source;
}
?>